package com.runa.monitor.platinterface.extend.third.comm.controller;

import com.alibaba.fastjson.JSON;
import com.runa.monitor.comm.dto.newComm.HotMeterVO;
import com.runa.monitor.comm.dto.newComm.PanelVO;
import com.runa.monitor.comm.dto.newComm.ValveVO;
import com.runa.monitor.platinterface.extend.third.comm.service.CommThirdService;
import com.runa.monitor.platinterface.extend.third.comm.vo.MeterData;
import com.runa.monitor.platinterface.extend.third.pojo.Result;
import com.runa.monitor.platinterface.extend.third.pojo.TemperaturePressureCurrentData;
import com.runa.monitor.platinterface.extend.third.vo.DockingDataResponseVo;
import com.runa.monitor.platinterface.extend.third.vo.HouseMeterDockingDataVo;
import com.runa.monitor.platinterface.extend.third.vo.TemperaturePressureDataDockingDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@EnableSwagger2
@Api("第三方上报")
@RestController
@RequestMapping("comm")
public class CommThirdController {

    @Resource
    private CommThirdService commThirdService;

    @ApiOperation("热表")
    @PostMapping("/api/hot/meter/data")
    public Result<List<DockingDataResponseVo>> batchSaveMeterData(String factory, String netDevice, @RequestBody List<HotMeterVO> hotMeterVOList) {
        log.info("第三方数据CommThirdController---batchSaveMeterData:" + JSON.toJSONString(hotMeterVOList) + "---" + factory);
        return commThirdService.batchSaveMeterData(factory, netDevice, hotMeterVOList);
    }

    @ApiOperation("阀")
    @PostMapping("/api/valve/data")
    public Result<List<DockingDataResponseVo>> batchSaveValveData(String factory, String netDevice, @RequestBody List<ValveVO> valveVOList) {
        log.info("第三方数据CommThirdController---batchSaveValveData:" + JSON.toJSONString(valveVOList) + "---" + factory);
        return commThirdService.batchSaveValveData(factory, netDevice, valveVOList);
    }

    @ApiOperation("阀门批量开度控制")
    @PostMapping("/api/valve/opening/control")
    public Object batchValveOpeningControl(@RequestBody String body) {
        log.info("阀门批量开度控制: {}", JSON.toJSONString(body));
        return null;
    }

    @ApiOperation("阀门批量回温控制")
    @PostMapping("/api/valve/outTemperature/control")
    public Object batchValveOutTemperatureControl(@RequestBody String body) {
        log.info("阀门批量回温控制: {}", JSON.toJSONString(body));
        return null;
    }

    @ApiOperation("面板")
    @PostMapping("/api/temp/panel/data")
    public Result<List<DockingDataResponseVo>> batchSavePanelData(String factory, String netDevice, @RequestBody List<PanelVO> panelVOList) {
        log.info("第三方数据CommThirdController---batchSavePanelData:" + JSON.toJSONString(panelVOList) + "---" + factory);
        return commThirdService.batchSavePanelData(factory, netDevice, panelVOList);
    }

    @ApiOperation("温压检测仪")
    @PostMapping("/api/temperaturepressure/data")
    public Result<List<DockingDataResponseVo>> batchSaveTemperaturePressureData(String factory, String netDevice, @RequestBody List<TemperaturePressureCurrentData> temperaturePressureCurrentDataList) {
        log.info("第三方数据CommThirdController---batchSaveTemperaturePressureData:" + JSON.toJSONString(temperaturePressureCurrentDataList) + "---" + factory);
        return commThirdService.batchSaveTemperaturePressureData(factory, netDevice, temperaturePressureCurrentDataList);
    }
}
